package org.xue.snowmall.order.web;

import entity.GoodsOrderEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.xue.snowmall.order.service.GoodsOrderService;
import org.xue.snowmall.common.utils.R;

import java.util.List;
import java.util.Map;

/**
 * @author 小刘的小张
 * @version 1.0
 * @description: TODO
 * @date 2021/9/23 17:13
 */
@Controller
public class WebGoodsOrderController {

    @Autowired
    private GoodsOrderService goodsOrderService;

    @PostMapping("/saveOrder")
    @ResponseBody
    public R order(@RequestParam Map<String, Object> params) {

        return goodsOrderService.saveOrder(params);
    }

    @RequestMapping("/findByUsmId")
    public String findByUsmId(Model model) {
        List<GoodsOrderEntity> orderList = goodsOrderService.findByUsmId();
        model.addAttribute("orderList", orderList);
        return "orderInfo";
    }

    @RequestMapping("toOrder")
    public String toOrder(@RequestParam Map<String, Object> params
            , Model model) {

        GoodsOrderEntity order = goodsOrderService.findByOsmId(params);
        model.addAttribute("order", order);
        return "order";
    }

}
